/*
 * Copyright (c) 2020. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package com.evenmo.string;

/**
 * This is Description 线程demo
 *
 * @author moyongjun
 * @date 2020/01/02
 */
public class ThreadDemo {

    public synchronized void m1(){
        System.out.println(Thread.currentThread().getName()+"m1 start ...");

        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+"m1 end");
    }


    public void m2(){
        System.out.println(Thread.currentThread().getName()+"m2 start ...");

        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName()+"m2 end");
    }


    public static void main(String[] args) {

        ThreadDemo t= new ThreadDemo();

        Runnable runnbale;

//        java8创建线程语法
//        Runnable runnable = () -> {t.m1()};
//        runnbale=()->t.m1();

        //创建两个线程，连个线程内部运行不同的方法
        new Thread(()->t.m1(), "线程1").start();

        Runnable runnbale2;
        new Thread(()->t.m2(), "线程2").start();

    }





}
